package handle

import (
	"context"
	exam "gitee.com/jinmingzhi/cdce-service/api/protos/exam/v1alpha"
	"gitee.com/jinmingzhi/cdce-service/internal/service"
	"github.com/golang/protobuf/ptypes/empty"
)

type Exam struct {
	schoolReportSvc service.SchoolReport
}

func NewExam (schoolReportSvc service.SchoolReport) *Exam {
	return &Exam{schoolReportSvc:schoolReportSvc}
}

func (e *Exam) List(ctx context.Context, _ *empty.Empty) (*exam.ListResp, error) {
	uid, err := GetUid(ctx)
	if err != nil {
		return nil, handlerErr(err)
	}

	data, err := e.schoolReportSvc.FindScoreByUid(ctx, uid)
	if err != nil {
		return nil, handlerErr(err)
	}
	return modelsToPbScore(data), nil
}

// 打印学生证
func (e *Exam) Print(ctx context.Context, _ *empty.Empty) (*exam.PrintResp, error) {
	return &exam.PrintResp{
		Code: "200",
		Msg:  "success",
	}, nil
}
